<template>
  <div class="singer-song">
    <div class="list">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <div v-for="(item, index) in list" :key="index" class="singer">
          <h4>{{ item.name }}</h4>
          <div class="singers">
            <span v-for="(singer, index) in item.ar" :key="index"
              >{{ singer.name }}
              <span v-show="index != item.ar.length - 1"> / </span>
            </span>
            <span v-show="item.al.name">
              <span>·</span>
              <span>{{ item.al.name }}</span>
            </span>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>
<script>
export default {
  props: ["singerId"],
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      this.$request("get", "/artist/top/song", {
        id: this.singerId,
      }).then((res) => {
        console.log(res);
        this.list = res.songs;

      });
    },
    onLoad() {
      setTimeout(() => {
        this.getData();
        this.loading = true;
      }, 1000);
    },
  },
};
</script>
<style scoped>
.header > span {
  font-size: 0.9rem;
}
.singer h4 {
  text-align: left;
  font-size: 1rem;
  padding: 0 2rem;
}
.singer {
  margin-bottom: 1rem;
}
.singers {
  text-align: left;
  padding: 0 2rem;
}
.singers span {
  color: rgb(147, 147, 147);
  font-size: 0.8rem;
}
.singers > span:nth-last-child(2) > span:first-child {
  color: red;
  font-weight: 900;
  padding: 0 0.5rem;
}
.singers > span:nth-last-child(1) > span:first-child {
  color: red;
  font-weight: 900;
  padding: 0 0.5rem;
}
.list {
  margin: 0 1rem;
}
</style>
